{include file="public/headerbase" /} {include file="public/left" /}
<div class="right-content">
	<ol class="breadcrumb we7-breadcrumb">
		<li>
			<a href="{:url('Cate/index')}">业务范围</a>
		</li>
		<li>
			编辑信息
		</li>
	</ol>
	<div class="clearfix">

		<form action="{:url('Cate/xiugai')}" method="post" class="we7-form" role="form" id="form1" enctype="multipart/form-data">
			<div class="form-group">
				<label class="col-sm-2 control-label">业务名称</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" name="cname" id="name" value="{$data['cname']}" placeholder="业务名称" />
				</div>
			</div>

			<div class="form-group">
				<div class="">
				<input type="hidden" name="cid" value="{$data.cid}" id="cid"/>
					<input type="button" class="btn btn-primary" value="保存"  id="btn"/>
				</div>
			</div>
		</form>
	
	</div>
	<script>
	$("#file0").change(function(){
	var objUrl = getObjectURL(this.files[0]) ;
	console.log("objUrl = "+objUrl) ;
	if (objUrl) {
		$("#img0").attr("src", objUrl) ;
	}
	}) ;
	//建立一個可存取到該file的url
	function getObjectURL(file) {
		var url = null ; 
		if (window.createObjectURL!=undefined) { // basic
			url = window.createObjectURL(file) ;
		} else if (window.URL!=undefined) { // mozilla(firefox)
			url = window.URL.createObjectURL(file) ;
		} else if (window.webkitURL!=undefined) { // webkit or chrome
			url = window.webkitURL.createObjectURL(file) ;
		}
		return url ;
	}
	$(function(){
		$("#btn").click(function(){
			var name=$("#name").val();
			var id=$("#cid").val();
			
			if(name!=='' && id!=='')
			{
				$.ajax({
					url: "{:url('Cate/xiugai')}",
					data:{"cname":name,"cid":id},
					type: "post",
					dataType: "json",
					success: function (mega) {
					  if(mega==1){
							/**alert("修改成功");
							location.href="{:url('Cate/index')}";**/
							util.message('修改成功', "{:url('Cate/index')}", 'info');
							
					   }else{
							util.message('修改失败', '', '');
					   }
					}
				});
			}
						
				
			
		})
	
	})
	</script>
</div>
</div>
</div>
</div>
</div>
{include file="public/footer" /}